const contract = require('@truffle/contract');
const UniswapV2Factory = contract(require('@uniswap/v2-core/build/UniswapV2Factory.json'))
const UniswapV2Router01 = contract(require('@uniswap/v2-periphery/build/UniswapV2Router01.json'))
const UniswapV2Router02 = contract(require('@uniswap/v2-periphery/build/UniswapV2Router02.json'))
const WETH9 = contract(require('@uniswap/v2-periphery/build/WETH9.json'))
const ERC20 = contract(require('@uniswap/v2-periphery/build/ERC20.json'))

UniswapV2Factory.setProvider(this.web3._provider);
UniswapV2Router01.setProvider(this.web3._provider);
UniswapV2Router02.setProvider(this.web3._provider);
WETH9.setProvider(this.web3._provider);
ERC20.setProvider(this.web3._provider);

module.exports = function (deployer, network, accounts) {
    deployer.deploy(UniswapV2Factory, accounts[0], {from: accounts[0]}).then(function() {
        return deployer.deploy(WETH9, {from: accounts[0]}).then(function() {
            deployer.deploy(UniswapV2Router01, UniswapV2Factory.address, WETH9.address, {from: accounts[0]});
            deployer.deploy(UniswapV2Router02, UniswapV2Factory.address, WETH9.address, {from: accounts[0]});
        });
    });
    return deployer.deploy(ERC20, 10000000000, {from: accounts[0]});
};
